<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/1
 * Time: 16:26
 */

namespace app\api\home;

use think\Controller;

class Base extends Controller
{
    /** 请求成功返回
     * @param array $data 返回参数
     * @param string $msg 提示信息
     * @return string
     */
    public function ajaxReturn($data=[],$msg='请求成功')
    {
        $return = [
            'code'=>0,
            'data'=>$data,
            'msg'=>$msg
        ];

        return json_encode($return);
    }

    /**
     * 请求失败返回
     * @param string $error 失败提示
     * @return string
     */
    public function ajaxError($error='请求失败')
    {
        $return = [
            'code'=>1,
            'error'=>$error,
        ];

        return json_encode($return);
    }
}